library(tidyverse)
library(cowplot)

df <- data.frame(time = rep(1:7, 3),
                 revenue = c(20, 25, 40, 45, 50, 55, 60,
                             10, 15, 20, 25, 30, 60, 65,
                             5, 10, 15, 20, 25, 30, 35),
                 treat = c(rep("early", 7),
                           rep("late", 7),
                           rep("never", 7)))

A <- ggplot(df, (aes(x = time, y = revenue, colour = treat))) +
  geom_line(alpha = .5)+
  theme_classic() +
  scale_color_manual(values = c("black", "lightgrey", "black")) +
  theme(legend.position = "none") +
  annotate(geom = "text", x = 3.5, y = 47,
           label = "Treated Early") +
  annotate(geom = "text", x = 6.5, y = 68,
           label = "Treated Late") +
  annotate(geom = "text", x = 6, y = 25,
           label = "Never Treated") +
  geom_vline(xintercept = 2, lty = 3) +
  labs(x = "Time",
       y = "Firm Revenue",
       title = "A: Treated Early vs. Never Treated Firms")+ 
  scale_x_continuous(breaks = 2,
                     labels = "Early Treament")

B <- ggplot(df, (aes(x = time, y = revenue, colour = treat))) +
  geom_line(alpha = .5)+
  theme_classic() +
  scale_color_manual(values = c("lightgrey", "black", "black")) +
  theme(legend.position = "none") +
  annotate(geom = "text", x = 3.5, y = 47,
           label = "Treated Early") +
  annotate(geom = "text", x = 6.5, y = 68,
           label = "Treated Late") +
  annotate(geom = "text", x = 6, y = 25,
           label = "Never Treated") +
  geom_vline(xintercept = 5, lty = 3) +
  labs(x = "Time",
       y = "Firm Revenue",
       title = "B: Treated Late vs. Never Treated Firms")+ 
  scale_x_continuous(breaks = 5,
                     labels = "Late Treament")
B

C <- ggplot(df, (aes(x = time, y = revenue, colour = treat))) +
  geom_line(alpha = .5)+
  theme_classic() +
  scale_color_manual(values = c("black", "black", "lightgrey")) +
  theme(legend.position = "none") +
  annotate(geom = "text", x = 3.5, y = 47,
           label = "Treated Early") +
  annotate(geom = "text", x = 3.5, y = 25,
           label = "Treated Late") +
  annotate(geom = "text", x = 3.5, y = 15,
           label = "Never Treated") +
  geom_vline(xintercept = 2, lty = 3) +
  labs(x = "Time",
       y = "Firm Revenue",
       title = "C: Treated Early vs. Treated Late,\nBefore Late Treatment") +
  scale_x_continuous(limits = c(1, 4),
                     breaks = 2,
                     labels = "Early Treament")
C

D <- ggplot(df, (aes(x = time, y = revenue, colour = treat))) +
  geom_line(alpha = .5)+
  theme_classic() +
  scale_color_manual(values = c("black", "black", "lightgrey")) +
  theme(legend.position = "none") +
  annotate(geom = "text", x = 3.5, y = 47,
           label = "Treated Early") +
  annotate(geom = "text", x = 6.5, y = 68,
           label = "Treated Late") +
  annotate(geom = "text", x = 6, y = 25,
           label = "Never Treated") +
  geom_vline(xintercept = 5, lty = 3) +
  labs(x = "Time",
       y = "Firm Revenue",
       title = "C: Treated Late vs. Treated Early,\nAfter Early Treatment") +
  scale_x_continuous(limits=c(3,7),
                     breaks = 5,
                     labels = "Late Treament")
D

GB_graph <- plot_grid(A, B, C, D)

ggsave(GB_graph, filename = "../images/FigureB3.pdf",
       width = 10, height = 10)
